import requests
# from fake_useragent import UserAgent   ###随机获取ua
import urllib3
import random  ##随机
from requests.adapters import HTTPAdapter   ### 重试

def ChromeOptionsUtil(chromePath, filePath):
    """
      谷歌无界面版
    :param phantomJs_Path:
    :param filePath:
    :return:
    """
    options = webdriver.ChromeOptions()
    # chrome_options = Options()
    options.add_argument("--headless")  # 设置谷歌为无界面模式
    # chrome_options.add_argument("--disable-gpu")
    file_Path = "file://" + os.getcwd() + filePath
    driver = webdriver.Chrome(chrome_options=options, executable_path=chromePath)  # 第一歌参数是谷歌options, 第二个参数是chromedriver的路径
    driver.get(file_Path)
    sleep(2)
    data = driver.page_source
    driver.close()
    driver.quit()
    return data


def sendGetRequest(url):
    s = requests.Session()
    urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
    try:
        data = s.get(url, headers=self.headers, verify=False)
    except Exception as e:
        print(e)
        return None
    return data


def print_hi(name):
    # Use a breakpoint in the code line below to debug your script.
    print(f'Hi, {name}')  # Press Ctrl+F8 to toggle the breakpoint.


# Press the green button in the gutter to run the script.
if __name__ == '__main__':
    print_hi('PyCharm')

# See PyCharm help at https://www.jetbrains.com/help/pycharm/
